﻿@{
    ViewBag.Title = "回货单列表";
}

@model PagerModel<ReturnOrder>

<div class="row">
    <div class="col-12">
        <div class="card">
            <div class="card-header">
                <form asp-action="Index" method="get" class="card-title">
                    <input type="hidden" name="CurrentPage" value="@Model.PageIndex" />
                    <input type="hidden" name="Sorting" value="@Model.FilterText" />
                    <div class="input-group">
                        <input type="text" name="FilterText" placeholder="请输入回货单号 ..." value="@Model.FilterText" class="form-control" />
                        <span class="input-group-append">
                            <button type="submit" class="btn btn-primary">查询</button>
                        </span>
                    </div>
                </form>

                <div class="card-tools">
                    <div class="btn-group">
                        @if (User.IsInRole(Consts.Supplier))
                        {
                            <a class="btn btn-default" asp-action="ReturnOrderEdit" asp-route-Id=@null>新&nbsp;增</a>
                            <button type="button" class="btn btn-default" onclick="RetunrOrderDel()">删&nbsp;除</button>
                            <button type="button" class="btn btn-default" onclick="ReturnOrderReview('@ExecuteActionEnum.审核')">审&nbsp;核</button>
                            <button type="button" class="btn btn-default" onclick="ReturnOrderReview('@ExecuteActionEnum.撤销审核')">撤&nbsp;审</button>
                            <button type="button" class="btn btn-default" onclick="ReturnOrderReview('@ExecuteActionEnum.复审')">复&nbsp;审</button>
                        }
                        <button type="button" class="btn btn-default" onclick="ReturnOrderReview('@ExecuteActionEnum.关闭')">关&nbsp;闭</button>
                    </div>
                </div>
            </div>
            <div class="card-body table-responsive p-3">
                <table class="table table-hover text-nowrap table-bordered">
                    <thead class="thead-dark">
                        <tr>
                            <th>
                                <input type="checkbox" id="ckbSelectAll" onchange="funCheckAll()" />
                            </th>
                            <th class="sr-only">ID</th>
                            <th>回货单号</th>
                            <th>采购单号</th>
                            <th>物料编码</th>
                            <th>物料名称</th>
                            <th>审核人</th>
                            <th>审核时间</th>
                            <th>审核状态</th>
                            <th>回货总数</th>
                            <th>回货类型</th>
                            <th>创建人</th>
                            <th>创建时间</th>
                            <th>备注</th>
                            @if (User.IsInRole(Consts.Supplier))
                            {
                                <th>操作</th>
                            }
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var item in Model.Data)
                        {
                            <tr>
                                <td>
                                    <input asp-for="@item.Checkbox" id="checked_@item.Id" class="tableSelectCheckBox" />
                                </td>
                                <td class="sr-only">@item.Id</td>
                                <td>
                                    <a asp-action="PreviewReturn" asp-route-Id="@item.Id">@item.ReturnOrderNo</a>
                                </td>
                                <td>@item.PurchaseOrders.PurchaseOrderNo</td>
                                <td>@item.ItemCode</td>
                                <td>@item.ItemName</td>
                                <td>@item.ReviewBy</td>
                                <td>@item.ReviewDate?.ToString("D")</td>
                                <td>@item.ReviewState</td>
                                <td>@item.ReturnOrderCount</td>
                                <td>@item.OrderType</td>
                                <td>@item.CreateBy</td>
                                <td>@item.CreateDate.ToString("D")</td>
                                <td>@item.Remark</td>
                                @if (User.IsInRole(Consts.Supplier))
                                {
                                    <td>
                                        <a asp-action="ReturnOrderEdit" asp-route-Id="@item.Id" class="btn btn-primary" onclick="FunEdit('@((int)item.ReviewState)', this)">编辑</a>
                                    </td>
                                }
                            </tr>
                        }
                    </tbody>
                </table>
            </div>
            <div class="card-footer">
                @await Html.PartialAsync("_Pagination")
            </div>
        </div>
    </div>
</div>
@section ReturnOrderJsFile{
    <script src="~/js/ReturnOrder.js" asp-append-version="true"></script>
}

    @await Html.PartialAsync("_ReturnOrderModal")